#include<iostream>
using namespace std;
const int N = 1e5 + 10;
int a[N];
int n, sum;
int main()
{
	int t;
	cin >> t;
	while (t--) {
		cin >> n >> sum;
		int sum1 = 0;
		for (int i = 1; i <= n; i++) {
			cin >> a[i];
			sum1 += a[i];
		}
		if (sum1 < sum) {
			cout << 0 << endl;
			continue;
		}
		int ans = 0;
		int cnt = n;
		int j = 1;
		for (int i = 1; i <= n; i++) {
			if (ans + a[i] < sum) {
				ans += a[i];
			}
			else {
				ans += a[i];
				//cout << "ans==" << ans << endl;
				while (ans >= sum) {
					cnt = min(cnt, i - j + 1);
					ans -= a[j];
					j++;
					//cout << "ans==" << ans << endl;
				}
				//cout << "j==" << j << endl;
			}
			//cout << "i==" << i << endl;
			//cout << "j==" << j << endl;
		}
		cout << cnt << endl;
	}
	return 0;
}